package com.example.attempt.service.impl;

import com.example.attempt.entity.Statistics;
import com.example.attempt.mapper.StatisticsMapper;
import com.example.attempt.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StatisticsServiceImpl implements StatisticsService {
    @Autowired
    StatisticsMapper statisticsMapper;

    @Override
    public Statistics getStatistics(int hid){
        return statisticsMapper.getStatistics(hid);
    }

    @Override
    public int addStatistics(Statistics sta){
        if(statisticsMapper.getStatistics(sta.getHid())!=null){
            return 1;
        }
        statisticsMapper.addStatistics(sta);
        return 0;
    }

    @Override
    public int updateStatistics(Statistics sta){
        statisticsMapper.updateStatistics(sta);
        return 0;
    }
}

